<template>
<div style="height:600px;box-sizing:border-box;padding:0 20px;overflow-y: auto; ">
   <el-button class="filter-item" size="mini" type="success" icon="el-icon-back"  @click="back">返回</el-button>
   <el-button class="filter-item" size="mini" type="success" icon="el-icon-s-claim"  @click="save">保存</el-button>
   <el-button class="filter-item" size="mini" type="success" icon="el-icon-s-help"  @click="modelAnalysis">模型分类</el-button>
  <div class="head_title">新增认定申请</div>
  <el-form ref="form" :model="form"  style="margin-top: 16px;" size="small" label-width="180px">
	<!-- <el-form-item label="客户名称"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.custName" style="width: 370px;"/>
    </el-form-item> --> 

    <el-form-item label="风险分类月份" style="display:inline-block;width:48%;margin-bottom:-2px">
			<!-- <el-form-item prop="date1">
					<el-date-picker  type="date"  v-model="form.custName"  value-format="yyyy-MM-dd"  style="width: 370px;" ></el-date-picker>
			</el-form-item>			 -->
			<el-input v-model="form.riskSortMonth"  :disabled="true" style="width: 370px;"/>
	</el-form-item>
	<el-form-item label="分类类型"  style="display:inline-block;width:48%;">
           <el-select v-model="form.sortType"  placeholder="请先选择分类类型" style="width: 370px;">
				<el-option
					v-for="item in dictMap.asset_sort_type"
					:key="item.id"
					:label="item.label"
					:value="item.value"/>
          </el-select>
      </el-form-item>
    

    <!-- <el-form-item label="业务品种"  style="display:inline-block;width:48%;">
           <el-select v-model="form.busiType"  placeholder="请先选择业务品种" style="width: 370px;">
				<el-option
					v-for="item in dictMap.busi_type"
					:key="item.id"
					:label="item.label"
					:value="item.value"/>
          </el-select>
      </el-form-item> -->
  </el-form>
  <div style="box-sizing:border-box;padding:0 320px 0 100px">
	  <el-table v-loading="loading" :data="data" size="small" style="width: 100%;"  @selection-change="handleSelectionChange">
		      <el-table-column type="selection" width="50"></el-table-column>
		      <el-table-column prop="debitNo" label="借据流水号"/>	 
			   <el-table-column prop="contractNo" label="合同流水号"/>
			   <el-table-column prop="custName" label="客户名称"/>
			   <el-table-column prop="riskSortMonth" label="会计月份"/>
			    <el-table-column label="业务品种" align="center">
					<template slot-scope="scope">
					<div v-for="item in dictMap.busi_type" :key="item.id">
						<span v-if="scope.row.busiType === item.value">{{ item.label }}</span>
					</div>
					</template>
                </el-table-column>
				<el-table-column prop="currency" label="币种"/>
				<el-table-column prop="contractAmount" label="借据余额"/>
				<!-- <el-table-column prop="sortResult" label="七级分类结果"/> -->

                <el-table-column label="七级分类结果" align="center">
					<template slot-scope="scope">
					<div v-for="item in dictMap.level_assetsort" :key="item.id">
						<span v-if="scope.row.sortResult == item.value">{{ item.label }}</span>
					</div>
					</template>
				</el-table-column>


				<el-table-column prop="applyNo" label="申请流水号"/>

				 <el-table-column v-if="checkPermission(['ADMIN','ASSETCERTIFICATE_ALL','ASSETMODEL_EDIT'])" label="调整"  align="center">
					<template slot-scope="scope">
						<el-button   v-permission="['ADMIN','ASSETCERTIFICATE_ALL','ASSETMODEL_EDIT']" size="mini" type="primary" icon="el-icon-more" @click="toAddjust(scope.row.debitNo)">调整</el-button>
					</template>
                </el-table-column>
	  </el-table>  
  </diV>

  </div>
</template>

<script>
import { get, update } from '@/api/alipay'
import { general,list,credentials,addCredentials,effective} from '@/api/custComBaseinfo'

import { applyAddList ,saveDate , modelAnalysis} from '@/api/assetClassificationInfo'

import { contractDetails } from '@/api/loanManageInfo'
import initData from '@/mixins/initData'
import initDict from '@/mixins/initDict'
import { parseTime } from '@/utils/index'
import checkPermission from '@/utils/permission'
export default {
  name: 'Config',
  mixins: [initData,initDict],
  data() {
    return {
	  dialog:false,
	  loading: false,
	  addLoading:false,
	  id:'',

	  ids:[],
	  id:'',

	  formAdd:{
		page: 0, 
		size: 10,
		sort:'id,desc',
	  },
      form: { 
		//    custNum:'',
		//    custName:'',
		//    busiType:'',
		//    paperContractNo:'',
		//    contractNo:'',
		//    contractAmount:'',
		//    currency:'',
		//    industryInvest:'',
		//    use:'',
		//    yearRate:'',
		//    rateFloatMode:'',
		//    rateFloatVal:'',
		//    monthRate:'',
		//    rateAdjustMode:'',
		//    repayMode:'',
		//    guaranteeMode:'',
		//    otherGuaranteeMode:'',
		//    contractStart:'',
		//    contractEnd:'',
		//    balance:'',
		//    overdueDays:'',
		//    fiveKind:'',
		//    endDate:'',
		//    remark:'',
		//    createUser:'',
		//    dept:'',
		//    createTime:'',
		//    updateUser:'',
		//    updateDept:'',
		//    updateTime:'',
		  
		   riskSortMonth:'',
		   sortType:'',
		   tempIds:[]
 
		 },
		  reqForm:{
			page: 0, 
			size: 10,
			sort:'orderNum,asc',
			custId:''
		},
		reqLoading:true,
		reqId:'',
		reqIds:[],
	    addForm:{
		   cardCountry:'',
		   cardType:'',
		   cardNum:'',
		   cardEndDate:'',
		   cardStatus:'',
		   cardPublishCity:'',
		   isMainCard:''
		},
		addRules: {
				cardCountry: [
				  { required: true, message: '请输入证件国别', trigger: 'blur' }
				],
				cardType: [
				  { required: true, message: '请输入证件类型', trigger: 'blur' }
				],
				cardNum: [
				  { required: true, message: '请输入证件编号', trigger: 'blur' }
				],
				cardEndDate: [
				  { required: true, message: '请输入证件到期日期', trigger: 'blur' }
				],
				cardStatus: [
				  { required: true, message: '请输入证件状态', trigger: 'blur' }
				],
				cardPublishCity: [
				  { required: true, message: '请输入证件发布城市', trigger: 'blur' }
				],
		        isMainCard: [
				  { required: true, message: '请输入是否主证件', trigger: 'blur' }
				]

		},

		effectiveParams:{
		   id:'',
		   cardStatus:''
		},
      rules: {
        appID: [
          { required: true, message: '请输入appID', trigger: 'blur' }
        ],
        sysServiceProviderId: [
          { required: true, message: '请输入商家账号', trigger: 'blur' }
        ],
        privateKey: [
          { required: true, message: '商户私钥不能为空', trigger: 'blur' }
        ],
        publicKey: [
          { required: true, message: '支付宝公钥不能为空', trigger: 'blur' }
        ],
        returnUrl: [
          { required: true, message: '回调地址不能为空', trigger: 'blur' }
        ],
        notifyUrl: [
          { required: true, message: '回调地址不能为空', trigger: 'blur' }
        ]
      }
    }
  },
  created() {
	  console.log('id----',this.$route.params.id)
	  //this.id = this.$route.params.id
     this.$nextTick(() => {
          this.getDictMap('busi_type,level_assetsort,asset_sort_type')
		  console.log('dictMap-------------',this.dictMap)
		  this.applyListAdd()
	 })


	  
	//   console.log('id--------------',this.id)
	//   	setTimeout(() => {
	// 			 this.id = sessionStorage.getItem('contractNo')
	// 			 //this.reqForm.custId = sessionStorage.getItem('contractNo')
	// 			 console.log('this.id',this.id)
	// 			 this.loading = true
	// 			 let that = this
    //              contractDetails(this.id).then(res => {
	// 				   this.loading = false
	// 				  // that.form = res
    //                   this.form = {
	// 					    custNum:res.custNum,
	// 						custName:res.custName,
	// 						busiType:res.busiType,
	// 						paperContractNo:res.paperContractNo,
	// 						contractNo:res.contractNo,
	// 						contractAmount:res.contractAmount,
	// 						currency:res.currency,
	// 						industryInvest:res.industryInvest,
	// 						use:res.use,
	// 						yearRate:res.yearRate,
	// 						rateFloatMode:res.rateFloatMode,
	// 						rateFloatVal:res.rateFloatVal,
	// 						monthRate:res.monthRate,
	// 						rateAdjustMode:res.rateAdjustMode,
	// 						repayMode:res.repayMode,
	// 						guaranteeMode:res.guaranteeMode,
	// 						otherGuaranteeMode:res.otherGuaranteeMode,
	// 						contractStart:res.contractStart,
	// 						contractEnd:res.contractEnd,
	// 						balance:res.balance,
	// 						overdueDays:res.overdueDays,
	// 						fiveKind:res.fiveKind,
	// 						endDate:res.endDate,
	// 						remark:res.remark,
	// 						createUser:res.createUser,
	// 						dept:res.dept,
	// 						createTime:res.createTime,
	// 						updateUser:res.updateUser,
	// 						updateDept:res.updateDept,
	// 						updateTime:res.updateTime,
	// 				  }
	// 				  console.log('this.form',this.form)

				
	// 				   console.log('res',res)
    //              }).catch(err => {
    //                    this.loading = false
    //                    console.log(err.response.data.message)
	// 			}) 
				


                
			   






    //      }, 500)
	  
  },
  methods: {
	   parseTime,
	   checkPermission,
	   beforeInit() {
		this.url = 'api/assetsort/assetCertificate/queryDebits'
		const sort = 'id,desc'
		const query = this.query
		const type = query.type
		const value = query.value
		const enabled = query.enabled
		this.params = { page: this.page, size: this.size }
		if (type && value) { this.params[type] = value }
		if (enabled !== '' && enabled !== null) { this.params['enabled'] = enabled }
		return true
		},
		toAddjust(debitNo){
             sessionStorage.setItem('adjustId',debitNo)
		     this.$router.push({ name: "applyAdjusts", params: { adjustId :debitNo} })  
		},
	back(){
		this.$router.push('/asset-classification/apply')
		// this.$router.go(-1)
	},
	modelAnalysis(){
          modelAnalysis().then(res => {
           
			 this.applyListAdd()
		  }).catch(err => {
				 console.log(err.response.data.message)
          })
	},
	applyListAdd(){
		//console.log('this.form',this.form)
		  applyAddList(this.formAdd).then(res => {
           // this.total = res.totalElements
			this.data = res.assetCertificateVos
			this.form.riskSortMonth = res.riskSortMonth
			setTimeout(() => {
                this.loading = false
             }, 170)
          }).catch(err => {
            this.loading = false
            console.log(err.response.data.message)
          })
	},

	handleSelectionChange(val) {
		  console.log('val',val)
		   val.forEach((v) => {
               this.ids.push(v.id)
		   });
		   console.log('ids',this.ids)
		   this.id = this.ids.toString()
           this.form.tempIds = this.ids
		   this.ids = []
	},
	save(){
		   if(this.form.tempIds.length==0){
			   this.$message.warning('请选择借据项')
			   return;
		   }else if(this.form.sortType == ''){
			   this.$message.warning('请选择分类类型')
			   return;
		   }
		   console.log('this.form',this.form)
            saveDate(this.form).then(res => {
				  // this.$router.push({ name: "apply" })  
				  this.$router.push('/asset-classification/apply')
				  
				  //  this.$router.go(-1)
			}).catch(err => {
                   this.loading = false
                    console.log(err.response.data.message)
            })
	},
	// handleSelectionChange(val) {
	// 	  console.log('val',val)
	// 	   val.forEach((v) => {
    //            this.reqIds.push(v.id)
	// 	   });
	// 	   console.log('ids',this.reqIds)
	// 	   this.reqId = this.reqIds.toString()
	// 	   this.reqIds = []
	// },
	add(){
		this.dialog = true;
	},
	cancelAdd(){
		this.resetForm()
	},
	resetForm() {
      this.dialog = false
	  this.$refs['forms'].resetFields()
	  this.addForm ={
           custId:'',

		   cardCountry:'',
		   cardType:'',
		   cardNum:'',
		   cardEndDate:'',
		   cardStatus:'',
		   cardPublishCity:'',
		   isMainCard:''
	  }
	},
	
 

  }
}
</script>

<style scoped> 
  .head_title{
    height:40px;line-height:40px;border-bottom: 2px solid #ce2731;color:#ce2731
  }
  .space{
	  margin-top:30px;
	  margin-bottom:10px
  }
   .one{
	   display:inline-block;
	   width:86.5%;
   }
   .two{
	   display:inline-block;
	   width:50%;
	
   }


</style>
